Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: double substate discard in eip-3860 #160

Merged

Conversation

vimpunk
Copy link
Contributor

@vimpunk vimpunk commented Mar 28, 2023

Details

More detail about the bug

The problem was that the current execution's memory stack substate was discarded immediately in the error path:

https://github.com/rust-blockchain/evm/blob/2e9c3b71f7b9ff241735f15145517d0627c469e6/src/executor/stack/executor.rs#L402-L409

while the transact_{call,create} methods also attempted to exit the same substate in their cleanup procedures:

https://github.com/rust-blockchain/evm/blob/2e9c3b71f7b9ff241735f15145517d0627c469e6/src/executor/stack/executor.rs#L346-L355

E.g., cleanup_for_call calls exit_substate here: https://github.com/rust-blockchain/evm/blob/2e9c3b71f7b9ff241735f15145517d0627c469e6/src/executor/stack/executor.rs#L989

However, because such a substate no longer existed at that point and only the root substate remained, the executor would panic as the root substate cannot be removed.

Context - the test case that triggered the bug

The way this error surfaced was when the initial StackExecutor::transact_{call,create} executed code that contained a CREATE/2 opcode which resulted in a call to <StackExecutor as Handler>::create.

Specifically, the st_random and st_random2 tests were failing, e.g. the randomStatetest307 test case contained code what would try to create a contract with an initcode size of 50k bytes that exceeded the initcode size limit and thus triggered the error path in the nested create call (CREATE opcode).

@sorpaas sorpaas merged commit b436a7f into rust-ethereum:master Apr 18, 2023
zjb0807 added a commit to AcalaNetwork/Acala that referenced this pull request Jan 22, 2024
zjb0807 added a commit to AcalaNetwork/Acala that referenced this pull request Jan 29, 2024
* update PrecompileHandle ref: rust-ethereum/evm#122

* update fee calculation ref: rust-ethereum/evm#132

* add code_size/code_hash fn in StackState trait ref: rust-ethereum/evm#140

* update evm call stack ref: rust-ethereum/evm#136

* update evm call stack ref: rust-ethereum/evm#155

* add shanghai eips 3651, 3855, 3860 ref: rust-ethereum/evm#152

* update is_precompile ref: rust-ethereum/evm#157

* fix eip-3860 ref: rust-ethereum/evm#160

* update runtime config ref: rust-ethereum/evm#161

* add eip-4399 ref: rust-ethereum/evm#162

* fix eip-2618 ref: rust-ethereum/evm#163

* fix nonce back to U256 ref: rust-ethereum/evm#166

* remove exit_substate in create functions ref: rust-ethereum/evm#168

* record external cost ref: rust-ethereum/evm#170

* add record_external_operation ref: rust-ethereum/evm#171

* add storage_growth ref: rust-ethereum/evm#173

* update evm

* switch to shanghai hardfork

* update ecrecover ref: polkadot-evm/frontier#964 (#2696)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants